home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
58189
/
58189.xpi
/
chrome
/
content
/
overlay.js
next >
Wrap
Text File
|
2010-01-06
|
2KB
|
63 lines
/*
* This overlay listens for mouse clicks on links or form submissions. Whenever
* a user initiates such an action, the information about this action is relayed
* to the Policy Information Point for later use.
*
* This code is heavily inspired by the "RequestPolicy" extension
*/
Components.utils.import("resource://csfiremodules/CsFireCommon.jsm");
CsFire.Overlay = new function() {};
/*
* This function will be executed at a load event. It will filter link clicks and
* form submissions and ignore other actions.
*/
CsFire.Overlay.onLoad = function(event) {
try {
var appcontent = document.getElementById("appcontent");
/*
* Register left mouse clicks on links. According to the developer information
* it's not possible to automate user-initiated clicks.
*
* http://developer.mozilla.org/en/DOM/element.click
*/
appcontent.addEventListener("click", function(event) {
// We're only interested in left-clicks on anchor tags.
if(event.target.nodeName.toLowerCase() == "a" && event.button == 0) {
CsFire.CsFireController.registerUserInteraction(event.target.href, event.target.ownerDocument.URL);
}
}, true);
/*
* Register human-initiated form submissions. According to the author of
* RequestPolicy, automatic form submission does not fire this event. After
* verification, we have come to the same conclusion.
*/
appcontent.addEventListener("submit", function(event) {
if (event.target.nodeName.toLowerCase() == "form") {
CsFire.CsFireController.registerUserInteraction(event.target.action, event.target.ownerDocument.URL);
}
}, true);
}
catch(e) {
CsFire.Logger.error("Error registering user interaction listeners: " + e);
}
};
/*
* Triggers the code to be run after an update or installation
* Needs to be here, to ensure that everything has loaded before it is executed
*/
CsFire.Overlay.onInstallOrUpdate = function() {
CsFire.CsFireController.performInstallAction();
window.removeEventListener("load",function(){ CsFire.Overlay.onInstallOrUpdate(); },true);
}
/*
* Register the event listener for user events whenever a page loads.
*/
addEventListener("load", function(event) { CsFire.Overlay.onLoad(event); }, false);
window.addEventListener("load",function(){ CsFire.Overlay.onInstallOrUpdate(); },true);